package com.itboye.lottery.adapter.base;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * Created by ZD on 2017/5/6.
 */

public abstract class ViewHolerAdapter<T extends ViewGroup> extends BaseAdapter {


    public abstract T onCreateViewHolder(int position, ViewGroup parent);

    public abstract void onBindViewHolder(int position, T t);

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        T view;
        if (convertView == null) {
            view = onCreateViewHolder(position, parent);
            view.setId(position);
            convertView = view;
            convertView.setTag(getItem(position));
        } else {
            view = (T) convertView;
        }
        onBindViewHolder(position, view);
        return convertView;
    }

}
